#ifndef _DevicesSPI_H_
#define _DevicesSPI_H_

#define SPI0_DMA_READ_LENGTH  (256)
#define SPI0_DMA_SEND_LENGTH  (256)

#define SET_SPI0_NSS_A_HIGH() GPIO_BOP(GPIOA) = GPIO_PIN_0
#define SET_SPI0_NSS_A_LOW()  GPIO_BC(GPIOA) = GPIO_PIN_0

#define SET_SPI0_NSS_G_HIGH() GPIO_BOP(GPIOA) = GPIO_PIN_1
#define SET_SPI0_NSS_G_LOW()  GPIO_BC(GPIOA) = GPIO_PIN_1




void vSPI0Init(void);
void vSPI0DMAInit(void);

uint8_t ucSPIWriteReadByte(uint32_t uiSpiPeriph, uint8_t ucByte);
int8_t cSPIWriteDatas(uint32_t uiSpiPeriph, uint8_t *pBuffer, int32_t iLength);
int8_t cSPIReadDatas(uint32_t uiSpiPeriph, uint8_t *pBuffer, int32_t iLength);

void vSPIxDMASetLenthStart(uint32_t dma_periph, dma_channel_enum channelx, uint32_t uiLength);
void vSPIxDMASetAddrAndLenthStart(uint32_t dma_periph, dma_channel_enum channelx, int8_t cDirection, uint32_t uiSourceAddress, uint32_t uiTargetAddress, uint32_t uiLength);
void vSPIxDMASendDatas(uint32_t uiUsartPeriph, uint8_t *pucDatas, int32_t iLength);


#endif
